// TypeScript file
class GuangGame extends eui.Component{
    public static GUANGGAO:string="guanggao";//设置的切换场景
    
    // 关闭按钮
    private close:eui.Button;

    // 下载按钮
    private xiazai:eui.Button;

    public constructor() {
        super();
    }

    public init(){
        this.skinName="resource/eui_skins/Guang.exml";
        console.log("进入广告")
        this.close.addEventListener(egret.TouchEvent.TOUCH_TAP,this.closeFun,this);
        
        this.xiazai.addEventListener(egret.TouchEvent.TOUCH_TAP,this.xaizaiFun,this);
    };

    // 关闭
    private closeFun() {
		var changeEvent = new ChangeEvent(ChangeEvent.CHANGE_EVENT);
		changeEvent.eventType = GameagentView.GAMEAGENT_VIEW;
		changeEvent.obj = this;
		SwitcherView.getInstance().dispatchEvent(changeEvent);
    };

    // 下载
    private xaizaiFun() {
        // location.href="http://android.myapp.com/myapp/detail.htm?apkName=com.colortab.icaoyao&ADTAG=mobile";
         platform.download();  
    }

    // 结束
    public endView(){
		if(this.close.hasEventListener(egret.TouchEvent.TOUCH_TAP))
			this.close.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.closeFun,this);
	};
}